-- card: 2949 from stack: in -- bmap block id: 0 -- flags: 0000 -- background id: 2599 -- name: ----- HyperTalk script ----- --WARNING!!! DON'T USE THIS SCRIPT. IT IS MODIFIED FOR THE DEMO. --USE THE VERSION IN THE BACKGROUND SCRIPT INSTEAD! on setLayer global objectNumber,objectType,optionState put the optionKey into optionState put theLayer() into doMenuWhich lock screen set lockMessages to true if objectType = "button" then choose btn tool else choose fld tool select the target repeat until the number of the target = objectNumber set cursor to busy if doMenuWhich < 0 then doMenu "Send Farther" if doMenuWhich > 0 then doMenu "Bring Closer" if doMenuWhich = 0 then exit repeat end repeat beep set cursor to 4 choose browse tool unlock screen set lockMessages to false put empty into objectNumber put empty into objectType put empty into optionState end setLayer function theLayer global objectNumber,objectType,optionState if the name of the target contains "field" then put "field" into objectType else put "button" into objectType end if if the name of the target contains "bkgnd" then put "bkgnd" into objectClass else put "card" into objectClass end if put the number of the target into fromThis if objectType = "button" then if the name of the target contains "bkgnd" then put the number of last bg btn into theRange else put the number of last btn into theRange end if else if objectType = "field" then if the name of the target contains "card" then put the number of last cd field into theRange else put the number of last field into theRange end if end if end if ask "Set " & objectClass &&objectType && fromThis && "to what number? (1-6)" if it is empty then exit to HyperCard set cursor to 4 put it into objectNumber if optionState is up then if objectNumber > 6 or objectNumber < 1 then answer "Sorry! “" &objectNumber & "” is not a valid " & objectType &&"number." exit to HyperCard else end if end if return objectNumber - fromThis end theLayer --WARNING!!! DON'T USE THIS SCRIPT. IT IS MODIFIED FOR THE DEMO. --USE THE VERSION IN THE BACKGROUND SCRIPT INSTEAD! -- part 1 (button) -- low flags: 00 -- high flags: 8004 -- rect: left=18 top=78 right=195 bottom=248 -- title width / last selected line: 0 -- icon id / first selected line: 27056 / 27056 -- text alignment: 1 -- font id: 3 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Card Button 1 ----- HyperTalk script ----- on mouseUp setlayer lock screen repeat with i = 1 to 6 set the name of cd btn i to "Card Button " & i end repeat unlock screen end mouseUp -- part 22 (button) -- low flags: 00 -- high flags: 8004 -- rect: left=24 top=80 right=96 bottom=241 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Card Button 2 ----- HyperTalk script ----- on mouseUp setlayer lock screen repeat with i = 1 to 6 set the name of cd btn i to "Card Button " & i end repeat unlock screen end mouseUp -- part 23 (button) -- low flags: 00 -- high flags: 8004 -- rect: left=30 top=93 right=109 bottom=235 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Card Button 3 ----- HyperTalk script ----- on mouseUp setlayer lock screen repeat with i = 1 to 6 set the name of cd btn i to "Card Button " & i end repeat unlock screen end mouseUp -- part 24 (button) -- low flags: 00 -- high flags: 8004 -- rect: left=36 top=106 right=122 bottom=228 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Card Button 4 ----- HyperTalk script ----- on mouseUp setlayer lock screen repeat with i = 1 to 6 set the name of cd btn i to "Card Button " & i end repeat unlock screen end mouseUp -- part 26 (button) -- low flags: 00 -- high flags: 8004 -- rect: left=49 top=132 right=148 bottom=215 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Card Button 5 ----- HyperTalk script ----- on mouseUp setlayer lock screen repeat with i = 1 to 6 set the name of cd btn i to "Card Button " & i end repeat unlock screen end mouseUp -- part 25 (button) -- low flags: 00 -- high flags: 8004 -- rect: left=42 top=119 right=135 bottom=222 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Card Button 6 ----- HyperTalk script ----- on mouseUp setlayer lock screen repeat with i = 1 to 6 set the name of cd btn i to "Card Button " & i end repeat unlock screen end mouseUp -- part 14 (button) -- low flags: 00 -- high flags: 2000 -- rect: left=4 top=23 right=62 bottom=44 -- title width / last selected line: 0 -- icon id / first selected line: 20098 / 20098 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Card Button 6 ----- HyperTalk script ----- on mouseUp go home end mouseUp -- part 27 (field) -- low flags: 01 -- high flags: 0004 -- rect: left=263 top=89 right=187 bottom=473 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 4 -- text size: 9 -- style flags: 0 -- line height: 12 -- part name: ----- HyperTalk script ----- on mouseUp setLayer repeat with i = 1 to 6 put "Card Field " &the number of cd fld i into line 1 of cd field i end repeat end mouseUp -- part 28 (field) -- low flags: 01 -- high flags: 0004 -- rect: left=273 top=100 right=178 bottom=462 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 4 -- text size: 9 -- style flags: 0 -- line height: 12 -- part name: ----- HyperTalk script ----- on mouseUp setLayer repeat with i = 1 to 6 put "Card Field " &the number of cd fld i into line 1 of cd field i end repeat end mouseUp -- part 29 (field) -- low flags: 01 -- high flags: 0004 -- rect: left=283 top=111 right=169 bottom=451 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 4 -- text size: 9 -- style flags: 0 -- line height: 12 -- part name: ----- HyperTalk script ----- on mouseUp setLayer repeat with i = 1 to 6 put "Card Field " &the number of cd fld i into line 1 of cd field i end repeat end mouseUp -- part 30 (field) -- low flags: 01 -- high flags: 0004 -- rect: left=293 top=122 right=160 bottom=441 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 4 -- text size: 9 -- style flags: 0 -- line height: 12 -- part name: ----- HyperTalk script ----- on mouseUp setLayer repeat with i = 1 to 6 put "Card Field " &the number of cd fld i into line 1 of cd field i end repeat end mouseUp -- part 31 (field) -- low flags: 01 -- high flags: 0004 -- rect: left=303 top=133 right=151 bottom=431 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 4 -- text size: 9 -- style flags: 0 -- line height: 12 -- part name: ----- HyperTalk script ----- on mouseUp setLayer repeat with i = 1 to 6 put "Card Field " &the number of cd fld i into line 1 of cd field i end repeat end mouseUp -- part 12 (field) -- low flags: 01 -- high flags: 4004 -- rect: left=253 top=78 right=196 bottom=484 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 4 -- text size: 9 -- style flags: 0 -- line height: 12 -- part name: ----- HyperTalk script ----- on mouseUp setLayer if the number of me = 6 then put "Change me to Card Field 1!" into line 5 of me set the showlines of me to true else put empty into line 5 of me set the showlines of me to false end if repeat with i = 1 to 6 put "Card Field " &the number of cd fld i into line 1 of cd field i end repeat end mouseUp -- part 32 (button) -- low flags: 00 -- high flags: 2000 -- rect: left=486 top=66 right=90 bottom=511 -- title width / last selected line: 0 -- icon id / first selected line: 2478 / 2478 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: New Button ----- HyperTalk script ----- on mouseUp set the visible of cd fld about to not the visible of cd fld about end mouseUp -- part 13 (button) -- low flags: 00 -- high flags: A002 -- rect: left=175 top=57 right=72 bottom=320 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 3 -- text size: 9 -- style flags: 16640 -- line height: 12 -- part name: Show Me The Script ----- HyperTalk script ----- on mouseUp --setlayer edit script of background end mouseUp -- part 33 (field) -- low flags: 81 -- high flags: 2007 -- rect: left=70 top=69 right=338 bottom=429 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 2 -- text size: 10 -- style flags: 0 -- line height: 13 -- part name: about ----- HyperTalk script ----- on mouseUp hide me set the scroll of me to 0 end mouseUp -- part contents for card part 31 ----- text ----- Card Field 5 -- part contents for card part 12 ----- text ----- Card Field 6 Change me to Card Field 1! -- part contents for card part 27 ----- text ----- Card Field 1 -- part contents for card part 28 ----- text ----- Card Field 2 -- part contents for card part 29 ----- text ----- Card Field 3 -- part contents for card part 30 ----- text ----- Card Field 4 -- part contents for background part 7 ----- text ----- Background Field 6 Change me to Background Field 1! -- part contents for background part 18 ----- text ----- Background Field 1 -- part contents for background part 21 ----- text ----- Background Field 2 -- part contents for background part 22 ----- text ----- Background Field 3 -- part contents for background part 23 ----- text ----- Background Field 4 -- part contents for background part 24 ----- text ----- Background Field 5 -- part contents for card part 33 ----- text ----- About "ChangeObjectLayer" 1.0... •You've heard of ShareWare and FreeWare! I now introduce TradeWare!!! This stack is TradeWare. If you find it useful, send me an 800K floppy packed with ShareWare and FreeWare goodies; I am especially interested in HyperCard development tools and utilities (such as XCMD/XFCNs, etc.—I already have the Developer Stack 1.2, Thank You), and system tools and utilities (INITs and CDEVs, etc). In return, I will send your disk back to you with ShareWare and FreeWare goodies from my own collection. No sound stacks, please—they're too obnoxious, and wasteful of disk space and memory. Please send neat (and/or useful) stuff to: Dean Wette 921 DeMun Avenue 2N Clayton, MO 63105 314-863-4944 scroll for more... EMail messages, complaints, suggestions, etc to me at: CIS 72317,2034 Remember, when TradeWare becomes rampant throughout the MacCommunity, you heard about it first in this stack!!! •Now...finally...about ChangeObjectLayer... While developing a stack containing numerous modal popup dialogs, fields, and buttons, I found myself constantly going to the "Objects" menu for the "Send Farther" and "Bring Closer" commands in order to move objects (buttons and fields) through different card and background layers. In some cases I wanted to obscure other objects, and in other cases I wanted to prevent objects from being obscured. Well, anyway, when you have 20 or more each of background and card buttons and fields, this menu selection (or its command key equivalent) business to change object layers can become quite tedious and boring. Therefore, I developed "ChangeObjectLayer" to automate and speed-up the process of moving objects' through different layers. "ChangeObjectLayer" works with both card and background buttons and fields. Try it out! On this card are six each of card and background buttons and fields. See the effect of changing a card/background button/field from 6 to 1 and vice versa. •To install "ChangeObjectLayer" do the following: 1) Click on the "Show Me The Script" button. 2) Copy the handler "setLayer" and the function "theLayer." 3) Paste them both into a card, background, or stack script. The best place for the "ChangeObjectLayer" scripts is in the stack script of your Home stack, thus making the script available in all stacks. •To invoke "ChangeObjectLayer" do the following: 1) Open the script editing window of the object (button or field) you want to change. 2a) If the object contains a script then add "setLayer" (with-out the quotes) as the second line of the objects script—the line following "on mouseUp." The part of the script following "setLayer" will be disabled until you remove the call to "setLayer." 2b) If the object does not already have a script then type the following script in the script editing window: on mouseUp setLayer end mouseUp 3) Click "OK" to close the editing window and then click on the object (make sure the browse tool is selected). Note: if the object is a field, then the lockText property must be set to true (i.e. lock the field) for "ChangeObjectLayer" to work. 4) You will be prompted to specify the number to which the object will be set. The prompt will indicate the valid range (e.g. "1-6" - you can't set a card button to 'card button 7' if there are only 6 card buttons). Enter a valid number, click "OK", and wait. "ChangeObjectLayer" will beep when it's finished with its task. 5) Remove the "setLayer" line from the object script to reenable any original object script. If the "setLayer" call is the second line of the object's script, it will be removed for you. •Notes: The "setLayer" handler concludes with an "exit to HyperCard" command so if you call it from an existing handler in a button or field, any script folowing the call will not execute until you remove the "setLayer" line of your object script. Sometimes, when an object is set to its highest or lowest number it may still obscure—or be obscured—by an object of its unlike type (field/button or vice versa). To remedy this, you may need to invoke "Send Farther" or "Bring Closer" additional times (i.e. use "Bring Closer" when an object is at its highest number already, or "Send Farther" when it is at its lowest number). This can be accomplished with "ChangeObjectLayer". If you hold down the optionkey while invoking the "setLayer" handler from an object, you can enter an invalid object number (such as 0 or 1,000,000). This will cause "ChangeObjectLayer" to invoke the "Send Farther" or "Bring Closer" menu commands forever. Press Command-. (period) to stop the repeated execution, and press Command-Tab to select the browse tool. The "setLayer" handler can be invoked once again in similar manner if necessary. •Well, that's about it for "ChangeObjectLayer" 1.0. I wrote and tested it on Friday, July, 29, 1988. If you find any bugs or have suggestions for improvements please let me know. Don't forget the TradeWare goodies! Dean Wette [72317,2034]